setTimeout(function () {
    $.ajax({
        url: '/profile',
        type: 'post',
        data: {'requestType': 'getPhone', 'userId': user.user_id},
        success: function (data, status) {
            if (status == 'success') {
                $("#telephone").html(data.user_phone)
            }
        },
        error: function (data, status) {
            if (status == 'error') {
                 alert('加载失败')
            }
        }
    });
}, 10)

function saveNumber() {
    var newNumber = $("#input_telephone").val()
    if (newNumber != null){
        var data = {'requestType': 'updatePhone', 'newNumber':newNumber, 'userId': user.user_id}
        $.ajax({
            url: '/profile',
            type: 'post',
            data: data,
            async: false,
            success: function (data, status) {
                if (status == 'success') {
                    alert('修改成功')
                    //保存成功以后刷新页面
                    window.location.href = 'profile.html'
                }
            },
            error: function (data, status) {
                if (status == 'error') {
                    alert('保存失败')
                }
            }
        });
    } else {
        alert('需要保存得联系电话，不允许为空')
    }
}